package com.ssy.lingxi.pay.entity;

import com.ssy.lingxi.pay.handler.converter.JpaJsonToAttachFileBOConverter;
import com.ssy.lingxi.pay.handler.converter.JpaJsonToIntegerConverter;
import com.ssy.lingxi.pay.model.bo.AttachFileBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 授信申请表
 * @author 伍将
 * @date 2020/8/14 19:37
 * @version 2.0.0
 */
@Entity
@Table(schema = "public", name = "pay_credit_apply",
        indexes = {@Index(name = "pay_credit_apply_credit_id_idx", columnList = "creditId"),
                @Index(name = "pay_credit_apply_member_id_idx", columnList = "memberId"),
                @Index(name = "pay_credit_apply_role_id_idx", columnList = "roleId"),
                @Index(name = "pay_credit_apply_parent_member_id_idx", columnList = "parentMemberId"),
                @Index(name = "pay_credit_apply_parent_role_id_idx", columnList = "parentMemberRoleId"),
                @Index(name = "pay_credit_apply_is_current_idx", columnList = "isCurrent"),
                @Index(name = "pay_credit_apply_lower_inner_status_idx", columnList = "lowerInnerStatus"),
                @Index(name = "pay_credit_apply_lower_superior_status_idx", columnList = "superiorInnerStatus"),
                @Index(name = "pay_credit_apply_outer_status_idx", columnList = "outerStatus")})
public class CreditApplyDO implements Serializable {
    private static final long serialVersionUID = 7790469678129881960L;

    /**
     * 授信申请id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "credit_apply_seq")
    @SequenceGenerator(sequenceName = "pay_credit_apply_seq", name = "credit_apply_seq", allocationSize = 1)
    private Long id;

    /**
     * 授信id
     */
    @Column(columnDefinition = "int8")
    private Long creditId;

    /**
     * 会员id
     */
    @Column(columnDefinition = "int8")
    private Long memberId;

    /**
     * 会员角色id
     */
    @Column(columnDefinition = "int8")
    private Long roleId;

    /**
     * 父级会员id
     */
    @Column(columnDefinition = "int8")
    private Long parentMemberId;

    /**
     * 父级会员角色id
     */
    @Column(columnDefinition = "int8")
    private Long parentMemberRoleId;

    /**
     * 外部工作流任务id
     */
    @Column(columnDefinition = "varchar(100)")
    private String outerTaskId;

    /**
     * 外部工作流类型
     */
    @Column(columnDefinition = "int")
    private Integer outerTaskType;

    /**
     * 内部工作流任务id
     */
    @Column(columnDefinition = "varchar(100)")
    private String innerTaskId;

    /**
     * 内部工作流类型
     */
    @Column(columnDefinition = "int")
    private Integer innerTaskType;

    /**
     * 申请单号
     */
    @Column(columnDefinition = "varchar(20)")
    private String applyNo;

    /**
     * 原有额度
     */
    @Column(columnDefinition = "decimal")
    private Double originalQuota;

    /**
     * 申请额度
     */
    @Column(columnDefinition = "decimal")
    private Double applyQuota;

    /**
     * 审批额度
     */
    @Column(columnDefinition = "decimal")
    private Double auditQuota;

    /**
     * 是否当前申请 0-否 1-是
     */
    @Column(columnDefinition = "int")
    private Integer isCurrent;

    /**
     * 申请类型 1-外部 2-内部
     */
    @Column(columnDefinition = "int")
    private Integer applyType;

    /**
     * 内部工作流当前步骤
     */
    @Column(columnDefinition = "int default 0")
    private Integer innerTaskStep = 0;

    /**
     * 内部工作流步骤记录
     */
    @Convert(converter = JpaJsonToIntegerConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<Integer> innerTaskStepRecord = new ArrayList<>();

    /**
     * 下级内部状态，CreditApplyLowerInnerStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer lowerInnerStatus;

    /**
     * 上级内部状态，CreditApplySuperiorInnerStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer superiorInnerStatus;

    /**
     * 外部状态， 0或Null-所有 1-待提交 2-待确认 3-接受申请 4-不接受申请
     */
    @Column(columnDefinition = "int")
    private Integer outerStatus;

    /**
     * 申请时间
     */
    @Column(columnDefinition = "int8")
    private Long applyTime;

    /**
     * 账单日
     */
    @Column(columnDefinition = "int")
    private Integer billDay;

    /**
     * 还款周期
     */
    @Column(columnDefinition = "int")
    private Integer repayPeriod;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8")
    private Long createTime;

    /**
     * 更新时间
     */
    @Column(columnDefinition = "int8")
    private Long updateTime;

    /**
     * 是否删除 0-否 1-是
     */
    @Column(columnDefinition = "int")
    private Integer isDelete;

    /**
     * 附件文件
     */
    @Convert(converter = JpaJsonToAttachFileBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<AttachFileBO> fileList;

    public Double getAuditQuota() {
        return auditQuota;
    }

    public void setAuditQuota(Double auditQuota) {
        this.auditQuota = auditQuota;
    }

    public List<AttachFileBO> getFileList() {
        return fileList;
    }

    public void setFileList(List<AttachFileBO> fileList) {
        this.fileList = fileList;
    }

    public Integer getOuterTaskType() {
        return outerTaskType;
    }

    public void setOuterTaskType(Integer outerTaskType) {
        this.outerTaskType = outerTaskType;
    }

    public String getInnerTaskId() {
        return innerTaskId;
    }

    public void setInnerTaskId(String innerTaskId) {
        this.innerTaskId = innerTaskId;
    }

    public Integer getInnerTaskType() {
        return innerTaskType;
    }

    public void setInnerTaskType(Integer innerTaskType) {
        this.innerTaskType = innerTaskType;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getCreditId() {
        return creditId;
    }

    public void setCreditId(Long creditId) {
        this.creditId = creditId;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getOuterTaskId() {
        return outerTaskId;
    }

    public void setOuterTaskId(String outerTaskId) {
        this.outerTaskId = outerTaskId;
    }

    public String getApplyNo() {
        return applyNo;
    }

    public Long getParentMemberId() {
        return parentMemberId;
    }

    public void setParentMemberId(Long parentMemberId) {
        this.parentMemberId = parentMemberId;
    }

    public void setApplyNo(String applyNo) {
        this.applyNo = applyNo;
    }

    public Double getOriginalQuota() {
        return originalQuota;
    }

    public void setOriginalQuota(Double originalQuota) {
        this.originalQuota = originalQuota;
    }

    public Double getApplyQuota() {
        return applyQuota;
    }

    public void setApplyQuota(Double applyQuota) {
        this.applyQuota = applyQuota;
    }

    public Integer getIsCurrent() {
        return isCurrent;
    }

    public void setIsCurrent(Integer isCurrent) {
        this.isCurrent = isCurrent;
    }

    public Integer getApplyType() {
        return applyType;
    }

    public void setApplyType(Integer applyType) {
        this.applyType = applyType;
    }

    public Integer getOuterStatus() {
        return outerStatus;
    }

    public void setOuterStatus(Integer outerStatus) {
        this.outerStatus = outerStatus;
    }

    public Long getApplyTime() {
        return applyTime;
    }

    public void setApplyTime(Long applyTime) {
        this.applyTime = applyTime;
    }

    public Integer getBillDay() {
        return billDay;
    }

    public void setBillDay(Integer billDay) {
        this.billDay = billDay;
    }

    public Integer getRepayPeriod() {
        return repayPeriod;
    }

    public void setRepayPeriod(Integer repayPeriod) {
        this.repayPeriod = repayPeriod;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public Long getParentMemberRoleId() {
        return parentMemberRoleId;
    }

    public void setParentMemberRoleId(Long parentMemberRoleId) {
        this.parentMemberRoleId = parentMemberRoleId;
    }

    public Integer getInnerTaskStep() {
        return innerTaskStep;
    }

    public void setInnerTaskStep(Integer innerTaskStep) {
        this.innerTaskStep = innerTaskStep;
    }

    public List<Integer> getInnerTaskStepRecord() {
        return innerTaskStepRecord;
    }

    public void setInnerTaskStepRecord(List<Integer> innerTaskStepRecord) {
        this.innerTaskStepRecord = innerTaskStepRecord;
    }

    public Integer getLowerInnerStatus() {
        return lowerInnerStatus;
    }

    public void setLowerInnerStatus(Integer lowerInnerStatus) {
        this.lowerInnerStatus = lowerInnerStatus;
    }

    public Integer getSuperiorInnerStatus() {
        return superiorInnerStatus;
    }

    public void setSuperiorInnerStatus(Integer superiorInnerStatus) {
        this.superiorInnerStatus = superiorInnerStatus;
    }
}
